<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../lib/vue-2.6.12.js"></script>
</head>
<body>

    <div id="app">
        <!-- 只有在key 是enter时，调用vm.submit   在key是esc 时  调用vm.clearInput -->
        <input type="text" @keyup.enter="submit" @keyup.esc="clearInput">

    </div>

    <script>
        const vm = new Vue({
            el: '#app',
            methods: {
                submit () {
                    console.log('触发submit方法');
                },
                clearInput(e) {
                    console.log('调用clearInput');
                    e.target.value = ''
                }
            }
        })

    </script>
</body>
</html>